﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Root="clr-namespace:Elysium.Theme">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium.Theme;component/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type ScrollViewer}">

        <Setter Property="Background" Value="{StaticResource Transparent}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="FontFamily" Value="{x:Static Root:Parameters.FontFamily}"/>
        <Setter Property="FontSize" Value="{x:Static Root:Parameters.TextFontSize}"/>
        <Setter Property="FontWeight" Value="Normal"/>

        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="0"/>

        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid Background="{StaticResource Transparent}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                    Grid.Column="0"
                                                    Grid.Row="0"
                                                    Content="{TemplateBinding Content}"
                                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                                    CanContentScroll="{TemplateBinding CanContentScroll}"
                                                    CanHorizontallyScroll="False"
                                                    CanVerticallyScroll="False"
                                                    Margin="{TemplateBinding Padding}"
                                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <Rectangle Grid.Column="0"
                                       Grid.Row="0"
                                       Stretch="Fill"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Bottom"
                                       Height="{TemplateBinding Root:Parameters.ScrollViewerShadowSize}"
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}">
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                        <GradientStop Color="{Binding Color, Source={StaticResource Transparent}}" Offset="0"/>
                                        <GradientStop Color="{Binding Color, Source={StaticResource Semitransparent}}" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle Grid.Column="0"
                                       Grid.Row="0"
                                       Stretch="Fill"
                                       HorizontalAlignment="Right"
                                       VerticalAlignment="Stretch"
                                       Width="{TemplateBinding Root:Parameters.ScrollViewerShadowSize}"
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}">
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                        <GradientStop Color="{Binding Color, Source={StaticResource Transparent}}" Offset="0"/>
                                        <GradientStop Color="{Binding Color, Source={StaticResource Semitransparent}}" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ScrollBar x:Name="PART_HorizontalScrollBar"
                                       Grid.Column="0"
                                       Grid.Row="1"
                                       AutomationProperties.AutomationId="HorizontalScrollBar"
                                       Cursor="Arrow"
                                       Orientation="Horizontal"
                                       Minimum="0"
                                       Maximum="{TemplateBinding ScrollableWidth}"
                                       Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HorizontalOffset, Mode=OneWay}"
                                       ViewportSize="{TemplateBinding ViewportWidth}"
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                            <ScrollBar x:Name="PART_VerticalScrollBar"
                                       Grid.Column="1"
                                       Grid.Row="0"
                                       AutomationProperties.AutomationId="VerticalScrollBar"
                                       Cursor="Arrow"
                                       Orientation="Vertical"
                                       Minimum="0"
                                       Maximum="{TemplateBinding ScrollableHeight}"
                                       Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=VerticalOffset, Mode=OneWay}"
                                       ViewportSize="{TemplateBinding ViewportHeight}"
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
    </Style>

</ResourceDictionary>